import request from '../utils/request';

// 获取库存列表
export const getInventoryList = (params = {}) => {
  return request({
    url: '/inventory',
    method: 'GET',
    params
  });
};

// 获取库存统计
export const getInventoryStats = () => {
  return request({
    url: '/inventory/stats',
    method: 'GET'
  });
};

// 获取库存分类
export const getInventoryCategories = () => {
  return request({
    url: '/inventory/categories',
    method: 'GET'
  });
};

// 获取单个库存项
export const getInventoryItem = (id) => {
  return request({
    url: `/inventory/${id}`,
    method: 'GET'
  });
};

// 创建库存项
export const createInventoryItem = (data) => {
  return request({
    url: '/inventory',
    method: 'POST',
    data
  });
};

// 更新库存项
export const updateInventoryItem = (id, data) => {
  return request({
    url: `/inventory/${id}`,
    method: 'PUT',
    data
  });
};

// 更新库存数量
export const updateInventoryStock = (id, data) => {
  return request({
    url: `/inventory/${id}/stock`,
    method: 'PATCH',
    data
  });
};

// 删除库存项
export const deleteInventoryItem = (id) => {
  return request({
    url: `/inventory/${id}`,
    method: 'DELETE'
  });
};
